


//////////////////
// rootBar code //
//////////////////

function toolBarOver() 
{
	var fromEl = getParent(event.fromElement, isRoot);
	var toEl = getParent(event.toElement, isRoot);
	if (toEl == null || fromEl == toEl || toEl.className == "toolActive")
		return;
	
	var el = toEl;
	
	if (el.direction == null)
		el.direction = "vertical";	// set default value

	//findMenu(el);
	
	// check if any other menu is opened
	var menuBar = getParent(el, ismenuBar);
	
	el.className = "toolHighlight";
}	

function toolBarOut() {

	var fromEl = getParent(event.fromElement, isRoot);
	var toEl = getParent(event.toElement, isRoot);
	
	if (fromEl == null || fromEl == toEl)
		return;
		
	fromEl.className = "tool";
}

function toolBarUp() {

	var fromEl = getParent(event.srcElement, isRoot);
	if (fromEl == null)
		return;
		
	fromEl.className = "tool";
}


function toolBarClick() {

	var el = getParent(event.srcElement, isRoot);
	
	if (el == null)
		return;
		
	var RootBar = getParent(el, ismenuBar);

	if (el.className == "toolActive") {	// This might seem odd but the call to hideAllMenuScriptlets()
		el.className="tool";
	}
	else {
		toolBar.shownMenu = el.menu;
		el.className = "toolActive";
		toolBar.oldActive = el;
		window.event.cancelBubble = true;
	}
	

}

function isRoot(el) {
	return el.className.indexOf("tool") > -1;
}

function ismenuBar(el) {
	return el.className == "toolBar";
}

function getParent(el, f) {
	if (el == null) return null;
	else if (f(el)) return el;
	else return getParent(el.parentElement, f);
}
